<form class="layui-form layui-box" style='padding:25px 30px 20px 0' action="" method="post">

   <div class="layui-form-item">
        <label class="layui-form-label">父节点</label>
        <div class="layui-input-block">
            <select name='pid' class='layui-select full-width' style='display:block'>
                <#list nodes as pd>
                <option  ${(pd.id==node.pid)?string("selected","")}  value='${pd.id?c}'>+${pd.title!''}</option>
                </#list>
            </select>
        </div>
    </div>
    
    <div class="hr-line-dashed"></div>

    <div class="layui-form-item text-center">
        <input type='hidden' value='${node.id?c}' name='data-id'/>
        <button class="layui-btn" type='button' lay-submit lay-filter="*">保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消</button>
    </div>
</form>

<script>
layui.use(['form','upload'], function(){
	var form = layui.form();
	
	//监听提交
    form.on('submit(*)', function (data) {
    	console.log(data.field);
    	$.post('node/edit', data.field, function (result) { 
    		if(result.code==1){
	        	layer.closeAll();
	            layer.msg(result.msg, {
	                icon: 1,
	                shade: this.shade,
	                scrollbar: false,
	                time: 2000,
	                shadeClose: true
	            });//保存成功提示
	            $.form.reload();//刷新表单
	        }else{
	            layer.msg(result.msg, {
	                icon: 2,
	                shade: this.shade,
	                scrollbar: false,
	                time: 3000,
	                shadeClose: true
	            });
	        }
	        
		},"json");
        return false;
    });
	  
});

</script>